package com.sc.school.service.impl;

import com.sc.school.entity.Teacher;
import com.sc.school.mapper.TeacherMapper;
import com.sc.school.service.TeacherService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @program: sc0702
 * @description:
 * @author: LAN
 * @create: 2024-09-25 16:53
 * @version: 1.0
 **/
@Service
public class TeacherServiceImpl implements TeacherService {

    @Resource
    private TeacherMapper teacherMapper;


    @Override
    public void save(Teacher teacher) {

        if (teacher.getTno()!=null){
            update(teacher);
        }else {
            insert(teacher);
        }

    }

    private void update(Teacher teacher){
        teacherMapper.updateByPrimaryKey(teacher);
    }


    private void insert(Teacher teacher){
        teacherMapper.insert(teacher);
    }


    @Override
    public void delete(Integer tno) {
        teacherMapper.deleteByPrimaryKey(tno);
    }
}